package com.zjw.remotecall.streamacceptor;

import android.os.RemoteException;
import android.util.Log;


/**
 * @author ：zhong.jw
 * @date ：Created in 2022/4/9 9:11
 */
class ByteBinderImpl extends IByteBinder.Stub implements StreamAcceptor.IStream {

    /**
     * Construct the stub at attach it to the interface.
     *
     * @param descriptor:binder access
     */
    public ByteBinderImpl(String descriptor) {
        super(descriptor);
    }

    /**
     * 服务端
     */
    @Override
    public byte[] waitBytes(String key) throws RemoteException {
        //当前进程需要的缓存数据
        return StreamAcceptor.openInService().waitBytesForService(key);
    }

    @Override
    public byte[] waitForBytes(String key) {
        try {
            return waitBytes(key);
        } catch (RemoteException e) {
            Log.e("ByteBinderImpl: ", e.getMessage() == null ? "null-message" : e.getMessage());
        }

        return new byte[]{};
    }
}
